home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / inter33c.zip / INTLIST.E < prev    next >
Text File  |  1992-09-13  |  23KB  |  821 lines

  1. /****************************************************************/
  2. /*    EEL code file for editing the Interrupt List        */
  3. /*                                */
  4. /*    Written by Ralf Brown                    */
  5. /*    LastEdit: 12 Sep 92                    */
  6. /*                                */
  7. /*  This EEL file adds the following keybindings:        */
  8. /*    Shf-Alt-D add a Desc: section to the current entry    */
  9. /*    Alt-N    add a new note to current entry or data struct  */
  10. /*    Alt-P    add a Program: section to the current entry    */
  11. /*    Alt-R    insert Return: at start of line            */
  12. /*    Alt-S    insert SeeAlso: at start of line        */
  13. /*    F11    insert a blank separator line            */
  14. /*    ^F11    create Format of: header            */
  15. /*    Shf-F11    create Values for: header            */
  16. /*    Alt-F11 create Call with: header            */
  17. /*    Alt-F12    create Bitmask of: header            */
  18. /*    F12    add the interrupt number to the separator line    */
  19. /*        preceding the current entry            */
  20. /*    ^F12    jump to a specified entry            */
  21. /*                                */
  22. /*  Other:                            */
  23. /*    adds intlist-mode for .LST and .1ST files        */
  24. /*    switches current buffer into intlist-mode on loading    */
  25. /****************************************************************/
  26.  
  27. #include "eel.h"
  28.  
  29. keytable intlist_tab ;            /* key table for IntList mode */
  30.  
  31. /*=============================================================*/
  32. /*=============================================================*/
  33.  
  34. int empty_line()
  35. {
  36.    return (character(point-1) == '\n' && character(point) == '\n') ;
  37. }
  38.  
  39. /*=============================================================*/
  40. /*=============================================================*/
  41.  
  42. int is_separator_line()
  43. {
  44.    return (empty_line() || parse_string(1,"--------",NULL)) ;
  45. }
  46.  
  47. /*=============================================================*/
  48. /* search in the specified direction (1 = forward, -1 = back)  */
  49. /* for the next entry separator line                   */
  50. /*=============================================================*/
  51.  
  52. int to_separator_line(dir)
  53. int dir ;
  54. {
  55.    return search(dir,"\n--------") ;
  56. }
  57.  
  58. /*=============================================================*/
  59. /* Add "SeeAlso: " to the beginning of the current line unless */
  60. /* it is already present                       */
  61. /*=============================================================*/
  62.  
  63. command see_also() on intlist_tab[ALT('s')]
  64. {
  65.    int start = point ;
  66.    
  67.    to_begin_line() ;
  68.    if (parse_string(1,"SeeAlso: ",NULL) == 0)
  69.       stuff("SeeAlso: ") ;
  70.    else
  71.       point = start ;
  72. }
  73.  
  74. /*=============================================================*/
  75. /* Add a Desc: section if the current entry does not already   */
  76. /* have one; if there is already a Desc: section, move to the  */
  77. /* start of it                               */
  78. /*=============================================================*/
  79.  
  80. command desc() on intlist_tab[ALT('D')]
  81. {
  82.    int start = point ;
  83.  
  84.    if (to_separator_line(-1))        /* find previous separator line */
  85.       {
  86.       point++ ;                /* skip the newline */
  87.       nl_forward() ;            /* advance to first line of entry */
  88.       while (!is_separator_line() && !empty_line() &&
  89.          !parse_string(1,"Notes*:\t",NULL) &&
  90.          !parse_string(1,"SeeAlso: ",NULL) &&
  91.          !parse_string(1,"BUGS*:\t",NULL) &&
  92.          !parse_string(1,"Program: ",NULL))
  93.      {
  94.      if (parse_string(1,"Desc:\t",NULL))
  95.         {
  96.         point += 6 ;        /* skip the Desc: */
  97.         return ;            /* we're done */
  98.         }
  99.      if (!nl_forward())        /* hit end of file? */
  100.         break ;
  101.      }
  102.       stuff("Desc:\t\n") ;
  103.       point-- ;                /* back up over inserted newline */
  104.       }
  105.    else
  106.       {
  107.       point = start ;
  108.       say("Not in an interrupt entry") ;
  109.       }
  110. }
  111.  
  112. /*=============================================================*/
  113. /* Add a "Program: " section to the current entry if it does   */
  114. /* not have one; otherwise, move to the beginning of the       */
  115. /* Program: section                           */
  116. /*=============================================================*/
  117.  
  118. command program() on intlist_tab[ALT('p')]
  119. {
  120.    int start = point ;
  121.  
  122.    if (to_separator_line(-1))        /* find previous separator line */
  123.       {
  124.       point++ ;                /* skip the newline */
  125.       nl_forward() ;            /* advance to first line of entry */
  126.       while (!is_separator_line() && !empty_line() &&
  127.          !parse_string(1,"Notes*:\t",NULL) &&
  128.          !parse_string(1,"SeeAlso: ",NULL) &&
  129.          !parse_string(1,"BUGS*:\t",NULL))
  130.      {
  131.      if (parse_string(1,"Program: ",NULL))
  132.         {
  133.         point += 9 ;        /* skip the Program: */
  134.         return ;            /* we're done */
  135.         }
  136.      if (!nl_forward())        /* hit end of file? */
  137.         break ;
  138.      }
  139.       stuff("Program: \n") ;
  140.       point-- ;                /* back up over inserted newline */
  141.       }
  142.    else
  143.       {
  144.       point = start ;
  145.       say("Not in an interrupt entry") ;
  146.       }
  147. }
  148.  
  149. /*=============================================================*/
  150. /* Add "Note: " section to the current entry; change an           */
  151. /* existing Note: to Notes: and position at end of Note:       */
  152. /* section.                               */
  153. /*=============================================================*/
  154.  
  155. command note() on intlist_tab[ALT('n')]
  156. {
  157.    int len ;
  158.    int done = 0 ;
  159.    
  160.    to_begin_line() ;
  161.    while (!empty_line() && !parse_string(1,"\n--------",NULL))
  162.       if (!nl_reverse())
  163.      break ;
  164.    point++ ;                /* skip the newline */
  165.    nl_forward() ;            /* advance a line */
  166.    while (!is_separator_line() && !parse_string(1,"Notes*:\t",NULL) &&
  167.           !parse_string(1,"SeeAlso:",NULL) && !parse_string(1,"BUGS*:\t",NULL))
  168.       if (!nl_forward())        /* hit end of file? */
  169.      break ;
  170.    len = parse_string(1,"Notes*:\t",NULL) ;
  171.    if (len == 0) /* no notes section */
  172.       stuff("Note:") ;
  173.    else
  174.       {
  175.       if (len == 6)  /* Note: */
  176.      {
  177.      point += 4 ;
  178.      stuff("s") ;    /* change it to Notes: */
  179.      }
  180.       while (!is_separator_line() && !parse_string(1,"SeeAlso:",NULL))
  181.      nl_forward() ;
  182.       }
  183.    stuff("\t\n") ;
  184.    point-- ;
  185. }
  186.  
  187. /*=============================================================*/
  188. /* Insert "Return: " at the beginning of the current line, if  */
  189. /* not already present                           */
  190. /*=============================================================*/
  191.  
  192. command returns() on intlist_tab[ALT('r')]
  193. {
  194.    int len ;
  195.    int start = point ;
  196.    
  197.    to_begin_line() ;
  198.    if (parse_string(1,"Return: ",NULL) == 0)
  199.       stuff("Return: ") ;
  200.    else
  201.       point = start ;
  202. }
  203.  
  204. /*=============================================================*/
  205. /* insert a line of dashes prior to the current cursor line    */
  206. /*=============================================================*/
  207.  
  208. command separator_line() on intlist_tab[FKEY(11)]
  209. {
  210.    int i ;
  211.  
  212.    to_begin_line() ;
  213.    for (i = 0 ; i < 45 ; i++)
  214.       insert('-') ;
  215.    insert('\n') ;
  216. }
  217.  
  218. /*=============================================================*/
  219. /* type the name of a structure, then invoke this function     */
  220. /* to create the "Format of X:" and "Offset Size Descr" lines  */
  221. /*=============================================================*/
  222.  
  223. command structure_header() on intlist_tab[FCTRL(11)]
  224. {
  225.    int start = point ;
  226.  
  227.    to_begin_line() ;
  228.    if (parse_string(1,"Format of ",NULL) == 0)
  229.       {
  230.       stuff("Format of ") ;
  231.       to_end_line() ;
  232.       stuff(":\nOffset\tSize\tDescription\n 00h\t") ;
  233.       }
  234.    else
  235.       point = start ;
  236. }
  237.  
  238. /*=============================================================*/
  239. /* Turn the current line into the header for a "Values of"     */
  240. /* section                               */
  241. /*=============================================================*/
  242.  
  243. command value_header() on intlist_tab[FSHIFT(11)]
  244. {
  245.    int start = point ;
  246.    
  247.    to_begin_line() ;
  248.    if (parse_string(1,"Values for ",NULL) == 0)
  249.       {
  250.       stuff("Values for ") ;
  251.       to_end_line() ;
  252.       stuff(":\n ") ;
  253.       }
  254.    else
  255.       point = start ;
  256. }
  257.  
  258. /*=============================================================*/
  259. /* Turn the current line into the header of a "Call with"      */
  260. /* section                               */
  261. /*=============================================================*/
  262.  
  263. command call_with_header() on intlist_tab[FALT(11)]
  264. {
  265.    int start = point ;
  266.    
  267.    to_begin_line() ;
  268.    if (parse_string(1,"Call ",NULL) == 0)
  269.       {
  270.       stuff("Call ") ;
  271.       to_end_line() ;
  272.       stuff("with:\n") ;
  273.       }
  274.    else
  275.       point = start ;
  276. }
  277.  
  278. /*=============================================================*/
  279. /* Turn the current line into the header of a "Bitmask of"     */
  280. /* section                               */
  281. /*=============================================================*/
  282.  
  283. command bitmask_of_header() on intlist_tab[FALT(12)]
  284. {
  285.    int start = point ;
  286.    
  287.    to_begin_line() ;
  288.    if (parse_string(1,"Bitmask of ",NULL) == 0)
  289.       {
  290.       stuff("Bitmask of ") ;
  291.       to_end_line() ;
  292.       stuff(":\n") ;
  293.       }
  294.    else
  295.       point = start ;
  296. }
  297.  
  298. /*=============================================================*/
  299. /*=============================================================*/
  300.  
  301. char grab_entry_number(func_num)
  302. char *func_num ;
  303. {
  304.    char c ;
  305.    int i ;
  306.  
  307.    strcpy(func_num,"------------") ;    /* 12 dashes */
  308.    point++ ;                /* go to first char of separator line */
  309.    nl_forward() ;            /* go to first line of entry */
  310.    if (parse_string(1,"INT ",NULL) == 0)
  311.       return 0 ;            /* not an interrupt entry, so return */
  312.    point += 4 ;                /* skip the "INT " */
  313.    func_num[0] = curchar() ;        /* grab the interrupt number */
  314.    point++ ;
  315.    func_num[1] = curchar() ;
  316.    nl_forward() ;            /* skip to second line of entry */
  317.    if (parse_string(1,"[ \t]*A[LHX][ \t]=[ \t][0-9A-F][0-9A-F]+h",NULL))
  318.       {
  319.       re_search(1,"[ \t]*A") ;
  320.       c = curchar() ;
  321.       point += 4 ;            /* skip ch and " = " */
  322.       if (c != 'L')
  323.      {
  324.      grab(point,point+((c=='X')?4:2),func_num+2) ;
  325.      point += ((c=='X')?4:2) ;
  326.      func_num[(c=='H')?4:6] = '-' ;    /* grab() stuck a NUL into the string */
  327.      }
  328.       else /* c == 'L' */
  329.      {
  330.      func_num[4] = curchar() ;
  331.      point++ ;
  332.      func_num[5] = curchar() ;
  333.      point ++ ;
  334.      }
  335.       point++ ;
  336.       if (parse_string(1,"[ \t]*subfn [0-9A-F][0-9A-F]+h",NULL))
  337.      {
  338.      re_search(1,"[ \t]*subfn ") ;
  339.      func_num[6] = 'S' ;
  340.      func_num[7] = 'F' ;
  341.      for (i = 0 ; i < 4 ; i++)
  342.         {
  343.         c = curchar() ;
  344.         if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F'))
  345.            {
  346.            func_num[8+i] = c ;
  347.            point++ ;
  348.            }
  349.         else
  350.            break ;
  351.         }
  352.      }
  353.       nl_forward() ;            /* skip to third line of entry */
  354.       }
  355.    if (parse_string(1,"[ \t]*[BCDES][HILPSX] = [0-9A-F][0-9A-F]+h",NULL))
  356.       {
  357.       re_search(1,"[ \t]*") ;
  358.       func_num[6] = curchar() ;
  359.       point++ ;
  360.       func_num[7] = c = curchar() ;
  361.       point += 4 ;            /* skip curchar and " = " */
  362.       if (c == 'H' || c == 'L')
  363.      {
  364.      grab(point,point+2,func_num+8) ;
  365.      func_num[10] = '-' ;        /* grab() stuck a NUL into the string */
  366.      }
  367.       else /* c == 'X' || c == 'I' || c == 'P' || c == 'S' */
  368.      grab(point,point+4,func_num+8) ;
  369.       }
  370.    return 1 ;                /* successful and have func number */
  371. }
  372.  
  373. /*=============================================================*/
  374. /* Put the interrupt and function number into the separator    */
  375. /* line just above the intlist entry preceding the cursor pos  */
  376. /*=============================================================*/
  377.  
  378. int number_one_int()
  379. {
  380.    char func_num[13] ;            /* 2->int, 4->AX, 6->extra reg, NUL */
  381.    int oldpoint ;
  382.    
  383.    while (to_separator_line(-1))    /* find previous separator line */
  384.       {
  385.       oldpoint = point ;
  386.       if (grab_entry_number(func_num))    /* does it belong to an intlist entry? */
  387.      {                /*   if yes, success, else try again */
  388.      point = oldpoint + 11 ;    /* skip NL and first ten dashes */
  389.      delete(point,point+12) ;    /* replace 12 dashes by the function */
  390.      stuff(func_num) ;        /*   number and extra register */
  391.      point = oldpoint ;        /* back to start of line, allowing repeat */
  392.      return 1 ;
  393.      }
  394.       point = oldpoint ;
  395.       }
  396.    return 0 ;                /* if we get here, we failed */
  397. }
  398.  
  399. /*=============================================================*/
  400. /* Put the interrupt and function number into the separator    */
  401. /* line just above one or more intlist entries preceding the   */
  402. /* current cursor position, letting user know of progress      */
  403. /*=============================================================*/
  404.  
  405. command number_int() on intlist_tab[FKEY(12)]
  406. {
  407.    int i, hit_top = 0 ;
  408.    
  409.    for (i = 0 ; i < iter ; i++)
  410.       {
  411.       if (!number_one_int())
  412.      {
  413.      hit_top = 1 ;
  414.      say("No prior entry.") ;
  415.      break ;
  416.      }
  417.       if (((i+1) % 100) == 0)
  418.      say("%d...",i+1) ;
  419.       }
  420.    if (iter > 1 && !hit_top)
  421.       say("Done.") ;
  422.    iter = 1 ;
  423. }
  424.  
  425. /*=============================================================*/
  426. /*=============================================================*/
  427.  
  428. int line_has_see_also()
  429. {
  430.    int start = point ;
  431.    int len ;
  432.    
  433.    to_begin_line() ;
  434.    if ((len = parse_string(1,".*%([sS]ee ",NULL)) != 0)
  435.       {
  436.       point += len ;        /* go to start of cross-reference */
  437.       point += parse_string(1,"also ",NULL) ;
  438.       if (parse_string(1,"INT [0-9A-F]",NULL) ||
  439.       parse_string(1,"A[XHL] =",NULL)
  440.      )
  441.      {
  442.      point++ ;        /* move into reference */
  443.      return 1 ;
  444.      }
  445.       }
  446.    return 0 ;
  447. }
  448.  
  449. /*=============================================================*/
  450. /*=============================================================*/
  451.  
  452. int grab_int_reference(ref)
  453. char *ref ;
  454. {
  455.    int begin, start = point ;
  456.    
  457.    re_search(-1,"[, \t\n]") ;    /* backup to start of reference */
  458.    if (curchar() == '\n')    /* start of line? */
  459.       re_search(1,":[ \t]") ;    /* skip the SeeAlso: */
  460.    else if (character(point-1) == 'T' && character(point-2) == 'N')
  461.       point -= 3 ;
  462.    else
  463.       point++ ;            /* back to start of reference */
  464.    begin = point ;
  465.    re_search(1,"[,\n\"]") ;    /* find end of INT-spec */
  466.    point-- ;
  467.    if (curchar() == '\"')    /* extra string at end of INT-spec? */
  468.       {
  469.       point++ ;
  470.       re_search(1,"[\"\n]") ;    /* if yes, run to end of line or string */
  471.       }
  472.    grab(begin,point,ref) ;
  473.    point = start ;
  474.    return 0 ;
  475. }
  476.  
  477. /*=============================================================*/
  478. /*=============================================================*/
  479.  
  480. int parse_int_name(entry_name,id,extra_string)
  481. char *entry_name, *id, *extra_string ;
  482. {
  483.    int start = point ;
  484.    int i ;
  485.    char def_int[3] ;
  486.    char c, *last ;
  487.  
  488.    for (i = strlen(entry_name)-1 ; i >= 0 ; i--)
  489.       entry_name[i] = toupper(entry_name[i]) ;
  490.    strcpy(id,"------------") ;
  491.    if (strncmp(entry_name,"INT ",4) == 0)
  492.       {
  493.       id[0] = entry_name[4] ;
  494.       id[1] = entry_name[5] ;
  495.       entry_name += 6 ;
  496.       if (entry_name[0] == '/')
  497.      entry_name++ ;
  498.       }
  499.    else if (to_separator_line(-1))
  500.       {
  501.       id[0] = character(point+11) ;
  502.       id[1] = character(point+12) ;
  503.       }
  504.    point = start ;
  505.    c = entry_name[1] ;
  506.    if (entry_name[0] == 'A' && (c == 'X' || c == 'H' || c == 'L'))
  507.       {
  508.       entry_name += 2 ;
  509.       while (entry_name[0] == ' ' || entry_name[0] == '\t')
  510.      entry_name++ ;
  511.       if (entry_name[0] == '=')
  512.      entry_name++ ;
  513.       while (entry_name[0] == ' ' || entry_name[0] == '\t')
  514.      entry_name++ ;
  515.       if (c != 'L')
  516.      {
  517.          id[2] = entry_name[0] ;
  518.          id[3] = entry_name[1] ;
  519.      }
  520.       if (c == 'X')
  521.      {
  522.      id[4] = entry_name[2] ;
  523.      id[5] = entry_name[3] ;
  524.      entry_name += 4 ;
  525.      }
  526.       else
  527.      {
  528.      if (c == 'L')
  529.         {
  530.         id[2] = entry_name[0] ;
  531.         id[3] = entry_name[1] ;
  532.         }
  533.      entry_name += 2 ;
  534.      }
  535.       if (entry_name[0] == 'H')
  536.      entry_name++ ;
  537.       if (entry_name[0] == '/')
  538.      entry_name++ ;
  539.       }
  540.    if (index("ABCDES",entry_name[0]) && index("HILPSXF",entry_name[1]))
  541.       {
  542.       id[6] = entry_name[0] ;
  543.       c = id[7] = entry_name[1] ;
  544.       entry_name += 2 ;
  545.       while (entry_name[0] == ' ' || entry_name[0] == '\t')
  546.      entry_name++ ;
  547.       if (entry_name[0] == '=')
  548.      entry_name++ ;
  549.       while (entry_name[0] == ' ' || entry_name[0] == '\t')
  550.      entry_name++ ;
  551.       id[8] = entry_name[0] ;
  552.       id[9] = entry_name[1] ;
  553.       if (c != 'H' && c != 'L' && (c != 'F' || entry_name[2] != 'h'))
  554.      {
  555.      id[10] = entry_name[2] ;
  556.      id[11] = entry_name[3] ;
  557.      entry_name += 4 ;
  558.      }
  559.       else
  560.      entry_name += 2 ;
  561.       if (entry_name[0] == 'H')
  562.      entry_name++ ;
  563.       if (entry_name[0] == '/')
  564.      entry_name++ ;
  565.       }
  566.    if (entry_name[0] == '\"')
  567.       {
  568.       entry_name++ ;
  569.       strcpy(extra_string,entry_name) ;
  570.       last = index(extra_string,'\"') ;
  571.       if (last)
  572.      *last = '\0' ;
  573.       }
  574.    else
  575.       extra_string[0] = '\0' ;
  576.    return 0 ;
  577. }
  578.  
  579. /*=============================================================*/
  580. /*=============================================================*/
  581.  
  582. int hex2_to_int(c1,c2)
  583. char c1, c2 ;
  584. {
  585.    if (c1 >= '0' && c1 <= '9')
  586.       c1 -= '0' ;
  587.    else if (c1 >= 'A' && c1 <= 'F')
  588.       c1 = c1 - 'A' + 10 ;
  589.    else if (c1 >= 'a' && c1 <= 'f')
  590.       c1 = c1 - 'a' + 10 ;
  591.    else
  592.       return -1 ;
  593.    if (c2 >= '0' && c2 <= '9')
  594.       c2 -= '0' ;
  595.    else if (c2 >= 'A' && c2 <= 'F')
  596.       c2 = c2 - 'A' + 10 ;
  597.    else if (c2 >= 'a' && c2 <= 'f')
  598.       c2 = c2 - 'a' + 10 ;
  599.    else
  600.       return -1 ;
  601.    return 16*c1 + c2 ;
  602. }
  603.  
  604. /*=============================================================*/
  605. /*=============================================================*/
  606.  
  607. char hex_digit(val)
  608. int val ;
  609. {
  610.    if (val < 0)
  611.       return '-' ;
  612.    else if (val > 9)
  613.       return 'A' + val - 10 ;
  614.    else
  615.       return '0' + val ;
  616. }
  617.  
  618. /*=============================================================*/
  619. /*=============================================================*/
  620.  
  621. int scan_for_entry(entry,extra_str,first_entry)
  622. char *entry, *extra_str ;
  623. int *first_entry ;
  624. {
  625.    int ah, al, t1, t2, match, found ;
  626.    char buf[7] ;
  627.    
  628.    *first_entry = 0 ;
  629.    ah = hex2_to_int(entry[2],entry[3]) ;
  630.    while (1)
  631.       {
  632.       if (!to_separator_line(1))
  633.      return 0 ;    /* failed if hit end of file */
  634.       if (character(point+1) != entry[0] || character(point+2) != entry[1])
  635.      return 0 ;    /* failed if no longer on same interrupt */
  636.       t1 = hex2_to_int(character(point+3),character(point+4)) ;
  637.       if (t1 == ah)
  638.      break ;
  639.       else if (t1 > ah)
  640.      {
  641.      to_begin_line() ;
  642.      *first_entry = point ;
  643.      return 0 ;    /* no such entry */
  644.      }
  645.       }
  646.    nl_reverse() ;
  647.    *first_entry = point ;
  648.    found = 0 ;
  649.    al = hex2_to_int(entry[4],entry[5]) ;
  650.    while (1)
  651.       {
  652.       if (!to_separator_line(1))
  653.      return 0 ;    /* failed if hit end of file */
  654.       if (character(point+1) != entry[0] || character(point+2) != entry[1])
  655.      return 0 ;    /* failed if no longer on same interrupt */
  656.       t1 = hex2_to_int(character(point+3),character(point+4)) ;
  657.       if (t1 != ah)
  658.      return 0 ;    /* failed if no longer on same INT/AH combo */
  659.       t2 = hex2_to_int(character(point+5),character(point+6)) ;
  660.       if (t2 == al)
  661.      {
  662.      if (!found)
  663.         {
  664.         found = 1 ;
  665.         *first_entry = point ;
  666.         }
  667.      if (entry[6] != '-')
  668.         {
  669.         grab(point+7,point+12,buf) ;
  670.         match = strncmp(buf,entry+6,6) ;
  671.         if (match == 0)
  672.            {
  673.            *first_entry = point ;
  674.            break ;
  675.            }
  676.         else if (match > 0)
  677.            return 0 ;    /* no exact match, but return a partial match */
  678.         }
  679.      else
  680.         break ;
  681.      }
  682.       else if (t2 > al)
  683.      {
  684.      if (found)
  685.         break ;
  686.      else
  687.         {
  688.         to_begin_line() ;
  689.         *first_entry = point ;
  690.         return 0 ;    /* no such entry */
  691.         }
  692.      }
  693.       }
  694.    point = *first_entry ;    /* back to first matching entry */
  695.    
  696.    
  697.    return 1 ;            /* we were successful */
  698. }
  699.  
  700. /*=============================================================*/
  701. /*=============================================================*/
  702.  
  703. int goto_entry(entry_name)
  704. char *entry_name ;
  705. {
  706.    char int_id[13], extra_string[60] ;
  707.    int start = point, first_entry ;
  708.    int int_num, curr_int ;
  709.    char search_str[22] ;
  710.    char line_buf[90] ;
  711.    
  712.    parse_int_name(entry_name,int_id,extra_string) ;
  713.    int_num = hex2_to_int(int_id[0],int_id[1]) ;
  714.    if (to_separator_line(-1))
  715.       {
  716.       if (character(point+11) == '-')
  717.      curr_int = -1 ;
  718.       else
  719.      curr_int = hex2_to_int(character(point+11),character(point+12)) ;
  720.       if (int_num <= 0)
  721.      point = 0 ;        /* go to top of file */
  722.       else
  723.      {
  724.      if (curr_int < 0)
  725.         point = 0 ;        /* go to top of file */
  726.      strcpy(search_str,"----------") ;
  727.      search_str[10] = hex_digit((int_num-1) / 16) ;
  728.      search_str[11] = hex_digit((int_num-1) % 16) ;
  729.      search_str[12] = '\0' ;
  730.      search( (int_num<=curr_int)?-1:1, search_str) ;
  731.      to_begin_line() ;
  732.      }
  733.       }
  734.    else
  735.       point = 0 ;
  736.    if (!scan_for_entry(int_id,extra_string,&first_entry))
  737.       {
  738.       say("%s not found.",entry_name) ;
  739.       if (first_entry)
  740.      {
  741.      mark = start ;
  742.      point = first_entry ;
  743.      }
  744.       else
  745.      point = start ;
  746.       }
  747.    if (has_arg)
  748.      iter = 1 ;                /* don't search repeatedly */
  749.    return 0 ;
  750. }
  751.  
  752. /*=============================================================*/
  753. /*=============================================================*/
  754.  
  755. command goto_int() on intlist_tab[FCTRL(12)]
  756. {
  757.    char entry_name[60], def_entry[60] ;
  758.    int start = point ;
  759.  
  760.    to_begin_line() ;
  761.    if (parse_string(1,"SeeAlso: ",NULL) != 0)
  762.       {
  763.       point += 9 ;        /* skip the SeeAlso: */
  764.       if (point < start)    /* if we were originally to the right of     */
  765.      point = start ;    /* current position, go back to original pos */
  766.       grab_int_reference(def_entry) ;
  767.       get_strdef(entry_name,"Goto Interrupt",def_entry) ;
  768.       }
  769.    else if (line_has_see_also())
  770.       {
  771.       grab_int_reference(def_entry) ;
  772.       get_strdef(entry_name,"Goto Interrupt",def_entry) ;
  773.       }
  774.    else
  775.       get_string(entry_name,"Goto Interrupt: ") ;
  776.    point = start ;
  777.    goto_entry(entry_name) ;
  778.    if (has_arg)
  779.       iter = 1 ;
  780. }
  781.  
  782. /*=============================================================*/
  783. /* Put the current buffer into IntList major mode           */
  784. /*=============================================================*/
  785.  
  786. command intlist_mode()
  787. {
  788.    mode_keys = intlist_tab ;
  789.    intlist_tab[')'] = intlist_tab[']'] = (short) show_matching_delimiter;
  790.    delete_hacking_tabs = 0 ;
  791.    major_mode = strsave("IntList") ;
  792.    make_mode() ;
  793.    auto_indent = 0 ;
  794.    margin_right = 79 ;
  795.    want_backups = 1 ;
  796.    undo_size = 100000 ;     /* less than default 500,000 since list is so big */
  797. }
  798.  
  799. when_loading()
  800. {
  801.    char *curbuf ;
  802.  
  803.    want_backups = want_backups.default = 1 ;
  804.    strcpy(backup_name,"%pbak/%b%e") ;        /* put backups in BAK subdir */
  805.    one_window() ;
  806.    intlist_mode() ;
  807.    if (exist("interrup.1st"))
  808.       {
  809.       curbuf = bufname ;
  810.       bufname = "interrup.1st" ;
  811.       intlist_mode() ;
  812.       bufname = curbuf ;
  813.       }
  814. }
  815.  
  816. /*=============================================================*/
  817. /* automagically switch into interrupt list mode on .LST and .1ST files */
  818.  
  819. suffix_lst()   { intlist_mode(); }
  820. suffix_1st()   { intlist_mode(); }
  821.